/**
 * author:wos
 * time:2024-1-4
 * title:重置密码
 */
const parseQueryParams = require("../../../utils/parseQueryParams"),
    md5 = require("md5")

async function main(ctx, next) {
    const query = ctx.request.body
    //参数检查
    if (!query.userId || !query.password || query.password.length < 6) {
        global.response(ctx, {
            "status": 200,
            "code": 400,
            "data": null,
            "msg": '参数不正确'
        })
        return
    }

    try {
        const sql = `update sys_user set password = '${md5(query.password)}' where userId = ${query.userId}`
        let rs = await global.query(sql)
        global.response(ctx, {
            "status":200,
            "code": 200,
            "data": rs,
            "msg":'success'
        })
    } catch (err) {
        console.error(err)
        global.serverError(ctx)
    }
}
module.exports = main


